import requests
# 定义请求的url
url = "https://fanyi.baidu.com/sug"
# 定义请求头信息
headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0'
}
# post发送的数据
data = {'kw':'你好'}
# 发送请求
res = requests.post(url=url, headers=headers, data=data)
# 接收返回数据
code = res.status_code
if code == 200:
    print("请求成功")
    data = res.json()
    print(data) # {'errno': 0, 'data': [{'k': '你好', 'v': 'hello; hi; How do you do!'}, {'k': '你好吗', 'v': 'How do you do?'}, {'k': '你好，陌生人', 'v': '[电影]Hello Stranger'}]}
    if data['errno'] == 0:
        print('响应成功')
        # 你好
        print(data['data'][0]['k'])
        v = data['data'][0]['v']
        # How do you do!
        print(v.split(";")[-1])
        # hello; hi; How do you do!
        print(data['data'][0]['v'])